//
//  HomeCrowdThreeTableViewCell.m
//  ioschishan
//
//  Created by 马田成 on 2017/7/13.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "HomeCrowdThreeTableViewCell.h"
#import "HomeCrowdFundingPicCollectionViewCell.h"
@implementation HomeCrowdThreeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
//    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
//    
//    layout.itemSize = CGSizeMake((DEF_SCREEN_WIDTH - 60) / 3, 117);
//    
//    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(15, 0, DEF_SCREEN_WIDTH-30, 117) collectionViewLayout:layout];
//    //
//    [self.collectionView layoutIfNeeded];
//    //    self.automaticallyAdjustsScrollViewInsets = NO;
//    self.collectionView.pagingEnabled = NO;
//    self.collectionView.delegate = self;
//    self.collectionView.dataSource = self;
//    
//    
//    [self.collectionView registerNib:[UINib nibWithNibName:@"HomeCrowdFundingPicCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"HomeCrowdFundingPicCollectionViewCell"];
//    
//    self.collectionView.showsHorizontalScrollIndicator = NO;
//    self.collectionView.showsVerticalScrollIndicator = NO;
//    
//    
//    //    self.collectionView.bounces = NO;
//    self.collectionView.backgroundColor = [UIColor whiteColor];
//    [self addSubview:self.collectionView];

 
    
    
    // Initialization code
}
- (NSMutableArray *)photoDeleSourceaaa{
    if (!_arrOfPic) {
        _arrOfPic = [NSMutableArray array];
    }
    return  _arrOfPic;
}
- (void)setNum:(NSString *)num{
    
    _num = num;
    
    
    if ([num intValue] / 3 == 0) {
        num1 = 1;
        
    }else if ([num intValue] % 3 == 0) {
        
        num1 = [num intValue] / 3;
        
    }else {
        
        num1 = [num intValue] / 3 + 1;
        
    }

    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    
    layout.itemSize = CGSizeMake((DEF_SCREEN_WIDTH - 60) / 3, 117);
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(15, 55, DEF_SCREEN_WIDTH-30, 117*num1 + 5 *num1) collectionViewLayout:layout];
    //
    [self.collectionView layoutIfNeeded];
    //    self.automaticallyAdjustsScrollViewInsets = NO;
    self.collectionView.pagingEnabled = NO;
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    
    
    [self.collectionView registerNib:[UINib nibWithNibName:@"HomeCrowdFundingPicCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"HomeCrowdFundingPicCollectionViewCell"];
    
    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.showsVerticalScrollIndicator = NO;
    
    
    //    self.collectionView.bounces = NO;
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.collectionView];
    
}


//类别
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
    
}
//数量
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    NSLog(@"LLLLLLLLLLLLLLLLLLLLLLLLL%lu", (unsigned long)self.arrOfPic.count);
    
    return self.arrOfPic.count;
  //   return 3;
    
    
}
//内容

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    HomeCrowdFundingPicCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeCrowdFundingPicCollectionViewCell" forIndexPath:indexPath];
    NSString *urlWare=[self.arrOfPic[indexPath.row] valueForKey:@"path"];
    NSString *str=manage(AP_HOST, urlWare);
    
    [cell.img sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@""]];

    return cell;
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
